﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MethodWorx.CMS.Content;
using System.Web.Mvc;
using MethodWorx.CMS.UI.Application;
using MethodWorx.CMS.UI.Models.Shared;
using MethodWorx.CMS.Services;

namespace MethodWorx.CMS.UI.Models
{
    public class CreateAbstractPageTemplateModel
    {
        private SchemaService service;
        public PageTemplateBasicDetails PageTemplateBasicDetails { get; set; }
        public PageTemplate ChildPageTemplate { get; set; }
        public bool MasterPage { get; set; }

        public CreateAbstractPageTemplateModel(SchemaService service, Guid? id, bool masterPage)
            : this(service, id, new PageTemplateBasicDetails(), masterPage)
        {
        }
        
        public CreateAbstractPageTemplateModel(SchemaService service, Guid? id, PageTemplateBasicDetails details, bool masterPage)
        {
            this.service = service;
            this.PageTemplateBasicDetails = details;
            this.PageTemplateBasicDetails.ParentsSelectList =
                new SelectList(service.GetAbstractPageTemplates(), "Id", "Name");

            if (id.HasValue)
                this.ChildPageTemplate = service.GetPageTemplateById(id.Value);

            this.MasterPage = masterPage;
        }      
    }
}